Back to course home
0% completed
Vote For New Content
Oracle Hard
Integer to English Words (hard)
Solution: Integer to English Words
Trapping Rain Water (hard)
Solution: Trapping Rain Water
First Missing Positive (hard)
Solution: First Missing Positive
Merge K Sorted Lists (hard)
Solution: Merge K Sorted Lists
Max Points on a Line (hard)
Solution: Max Points on a Line
Sudoku Solver (hard)
Solution: Sudoku Solver
Longest Valid Parentheses (hard)
Solution: Longest Valid Parentheses
Remove Nth Node From End of List (Medium)
Solution: Remove Nth Node From End of List
Median of Two Sorted Arrays (hard)
Solution: Median of Two Sorted Arrays
Constrained Subsequence Sum (hard)
Solution: Constrained Subsequence Sum
Pairs of Songs With Total Durations Divisible by 60 (medium)
Problem Statement
You are given a list of positive integer times, where times[i] represents the duration of ith song in seconds.
Return the number of unique song pairs for which their total duration in seconds is multiple of 60. In other words, find the number of indices i, j such that i < j with (times[i] + times[j]) % 60 == 0.
Examples
Example 1:
- Input: times =
[30, 20, 150, 100, 40, 110] - Expected Output:
3 - Justification: The pairs of songs that can form a total duration divisible by 60 are (30, 150), (20, 100), and (20, 40). Each of these pairs sums up to a multiple of 60, hence the expected output is 3.
Example 2:
- Input: times =
[120, 180, 60] - Expected Output:
3 - Justification: The sum of (120, 180), (120, 60), and (180, 60) are divisible by 60. So, the expected output is 3.
Example 3:
- Input: times =
[15, 225, 90, 60] - Expected Output:
1 - Justification: The only pair of songs that can form a total duration divisible by 60 is (15, 225).
Try it yourself
Try solving this question here:
Java
. . . .
Solution: Single Element in a Sorted Array
Solution: Pairs of Songs With Total Durations Divisible by 60
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself